import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
const actions = {
}
const mutations = {
  DZ (state) {
    console.log('切换定制显示')
    state.isdz = !state.isdz
  },
  cm_menuid (state, value) {
    state.menuid = value
  },
  ORDER (state, value) {
    state.ordered.push(value)
  },
  SETADD1 (state, value) {
    state.add1 = value
  },
  SETADD2 (state, value) {
    state.add2 = value
  },
  SETADD3 (state, value) {
    state.add3 = value
  },
  SHOPUP (state) {
    console.log('切换购物车显示')
    state.isshop = !state.isshop
  },
  ORDERED_REMOVE (state, value) {
    console.log('mutations删除' + value)
    state.ordered.splice(value, 1)
  },
  ORDERED_REMOVEALL (state) {
    console.log('mutations删除全部')
    state.ordered = []
  }
}
const getters = {
  pricecount (state) {
    var sum = 0
    if (state.ordered.length === 0) {
      sum = 0
    } else {
      for (var item in state.ordered) {
        sum = sum + state.ordered[item].price
      }
    }
    return sum
  }
}
const state = {
  dishes: [// id：物品分类，name：物品名称，price：单价，imgurl：图片链接
    { id: 'rec', name: '至尊披萨（12寸）', price: 168, imgurl: 'rec/rec1.jpeg', btn: 'rec', addid: '0' },
    { id: 'rec', name: '一次满足披萨（10寸）', price: 168, imgurl: 'rec/rec2.jpeg', btn: 'sm', addid: '0' },
    { id: 'rec', name: '夏威夷披萨（10寸）', price: 108, imgurl: 'rec/rec3.jpeg', btn: 'pz', addid: '0' },
    { id: 'sm', name: '双人同享套餐', price: 288, imgurl: 'sm/sm1.jpeg', btn: 'ps', addid: '0' },
    { id: 'sm', name: '四分天下套餐', price: 388, imgurl: 'sm/sm2.jpeg', btn: 'ham', addid: '0' },
    { id: 'pz', name: '至尊披萨（12寸）', price: 168, imgurl: 'pz/pz1.jpeg', btn: 'sn', addid: '0' },
    { id: 'pz', name: '一次满足披萨（8寸）', price: 168, imgurl: 'pz/pz2.jpeg', btn: 'rec', addid: '0' },
    { id: 'pz', name: '夏威夷披萨（10寸）', price: 108, imgurl: 'pz/pz3.jpeg', btn: 'rec', addid: '0' },
    { id: 'pz', name: '榴莲披萨（8寸）', price: 88, imgurl: 'pz/pz4.jpeg', btn: 'rec', addid: '0' },
    { id: 'pz', name: '烟熏培根披萨（8寸）', price: 68, imgurl: 'pz/pz5.jpeg', btn: 'rec', addid: '0' },
    { id: 'pz', name: '番茄芝士披萨（8寸）', price: 68, imgurl: 'pz/pz6.jpeg', btn: 'rec', addid: '0' },
    { id: 'pa', name: '黑胡椒牛肉番茄意面', price: 68, imgurl: 'pa/pa1.jpeg', btn: 'rec', addid: '0' },
    { id: 'ham', name: '澳洲和牛堡套餐', price: 58, imgurl: 'ham/ham1.jpeg', btn: 'rec', addid: '0' },
    { id: 'sn', name: '塔塔香鸡腿', price: 28, imgurl: 'sn/sn1.jpeg', btn: 'rec', addid: '0' },
    { id: 'de', name: '雪媚娘', price: 8, imgurl: 'de/de1.jpeg', btn: 'rec', addid: '0' },
    { id: 'dr', name: '薄荷奶绿', price: 48, imgurl: 'dr/dr1.jpeg', btn: 'rec', addid: '0' },
    { id: 'se', name: '员工', price: 999, imgurl: 'se/se1.jpeg', btn: 'rec', addid: '0' }
  ],
  kinds: [
    { id: 'rec', name: '推荐', imgurl: 'recommend.png', btn: 'btnrec' },
    { id: 'sm', name: '套餐', imgurl: 'set_meal.png', btn: 'btnsm' },
    { id: 'pz', name: '披萨', imgurl: 'pizza1.png', btn: 'btnpz' },
    { id: 'pa', name: '意面', imgurl: 'pasta.png', btn: 'btnpa' },
    { id: 'ham', name: '汉堡', imgurl: 'hamburger.png', btn: 'btnham' },
    { id: 'sn', name: '小吃', imgurl: 'snack.png', btn: 'btnsn' },
    { id: 'de', name: '甜品', imgurl: 'dessert.png', btn: 'btnde' },
    { id: 'dr', name: '饮料', imgurl: 'drink.png', btn: 'btndr' },
    { id: 'se', name: '加料', imgurl: 'seasoning.png', btn: 'btnse' }
  ],
  ordered: [
  ],
  adds: [// addcount：特殊选项总数，add1：加料分类名称，add1count：单项总数
    { add1: '芝士量', add1_1: '少量', add1_2: '正常', add1_3: '大量', add2: '其他加料1', add2_1: '熏培根', add2_2: '牛肉片', add2_3: '小龙虾', add3: '其他加料2', add3_1: '橄榄', add3_2: '蘑菇', add3_3: '彩椒' }
  ],
  cart: [// count：件数
    { count: '0' }
  ],
  ticket: [],
  isdz: false,
  menuid: '0',
  add1: '',
  add2: '',
  add3: '',
  isshop: false
}

export default new Vuex.Store({
  state,
  getters,
  mutations,
  actions,
  modules: {
  }
})
